package cn.dai.servlet;

import cn.dai.dao.MenuDaoImpl;
import cn.dai.pojo.Menu;
import cn.dai.service.MenuService;
import cn.dai.service.MenuServiceImpl;
import cn.dai.service.model.Page;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author ArkD42
 * @file RBAC
 * @create 2020 - 06 - 14 - 1:52
 */
@WebServlet("/menu")
public class MenuServlet extends BaseServlet{

    MenuService menuService = new MenuServiceImpl(new MenuDaoImpl());

    /**
     * 跳转到菜单管理页面
     * /menu?act=menuList
     * @param request
     * @param response
     * @return
     */
    public String menuList(HttpServletRequest request, HttpServletResponse response){

        String page = request.getParameter("page");
        if (page == null ) page = "1";
        Integer i = Integer.valueOf(page);

        Page<Menu> menuPages = menuService.getMenuPages(i);
        request.setAttribute("menuPage",menuPages);

        return "forward:/WEB-INF/admin/menu/menuList.jsp";
    }


}
